﻿using System.Reflection;
using System.Web;
using System.Web.Mvc;
using Autofac;
using Autofac.Integration.Mvc;
using MovieDB;
using MovieDB.Autofac;
using MovieDB.AutofacRegistration;

[assembly: PreApplicationStartMethod(typeof (AppStart_AutofacMVC3), "Start")]

namespace MovieDB
{
    public class AppStart_AutofacMVC3
    {
        public static void Start()
        {
            var containerBuilder = new ContainerBuilder();

            AutofacRegister.RegisterAllComponents(containerBuilder, Assembly.GetExecutingAssembly());
            IContainer container = containerBuilder.Build();

            AutofacResolver.SetResolver(container);
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
        }
    }
}